﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;

/// <summary>
///db_slide 的摘要说明
/// </summary>
public class db_slide
{
    SqlDBClass db;
	public db_slide()
	{
        db = new SqlDBClass();
	}

    /// <summary>
    /// 增加幻灯片
    /// </summary>
    /// <param name="piclink"></param>
    /// <param name="slidetext"></param>
    /// <param name="slidelink"></param>
    /// <returns></returns>
    public Boolean addSlide(string piclink,string slidetitle, string slidetext, string slidelink)
    {
        string strsql = "Insert Into slide(piclink,slidetitle,slidetext,slidelink) Values('" + piclink + "','" + slidetitle+"','" + slidetext + "','" + slidelink + "')";
        return db.execSqlNoQuery(strsql);
    }

    public Boolean delSlide(string id) {
        string strsql = "delete from slide where id=" + id;
        return db.execSqlNoQuery(strsql);
    }

    /// <summary>
    /// 更新幻灯片
    /// </summary>
    /// <param name="id"></param>
    /// <param name="piclink"></param>
    /// <param name="slidetext"></param>
    /// <param name="slidelink"></param>
    /// <returns></returns>
    public Boolean updateSlide(string id, string piclink, string slidetitle,string slidetext, string slidelink)
    {
        string strsql = "update slide set piclink='" + piclink + "',slidetitle='" + slidetitle + "',slidetext='" + slidetext + "',slidelink='" + slidelink + "' where id=" + id;
        return db.execSqlNoQuery(strsql);
    }

    /// <summary>
    /// 查询前五条 幻灯片
    /// </summary>
    /// <returns></returns>
    public DataSet selectSlideALL() {
        string strsql = "select top 5 * from slide order by id desc";
        return db.execSql(strsql);
    }

    /// <summary>
    /// 查询单条 幻灯片
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    public DataSet selectSlideONE(string id)
    {
        string strsql = "select * from slide where id=" + id;
        return db.execSql(strsql);
    }

    /// <summary>
    /// 检查幻灯片是否已满5条
    /// </summary>
    /// <returns>未满：false；已满：true</returns>
    public Boolean isFullSlide() {
        string strsql = "select * from slide";
        DataSet ds = db.execSql(strsql);
        if (ds.Tables[0].Rows.Count < 5)
        {
            return false;
        }
        else
        {
            return true;
        }
    }
}